﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;

namespace DAO
{
    public class ChiTietPhieuGiaCong_DAO
    {
        private static ChiTietPhieuGiaCong_DAO m_instance = null;

        public static ChiTietPhieuGiaCong_DAO Instance
        {
            get
            {
                if (m_instance == null)
                    m_instance = new ChiTietPhieuGiaCong_DAO();
                return m_instance;
            }
        }

        /// <summary>
        ///   theem ct phieu gia cong
        /// </summary>
        /// 

        public bool ThemCTPhieuGiaCong(string _maphieugc, string _mahanggc, int _soluong, long _dongia)
        {
            try
            {
                SqlConnection cnn = SQLConnection.Instance.SqlConnection;
                SqlCommand cmd = new SqlCommand("ADD_CTPHIEUGIACONG", cnn);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add("@MaPhieuGC", SqlDbType.NVarChar, 10);
                cmd.Parameters["@MaPhieuGC"].Value = _maphieugc;

                cmd.Parameters.Add("@MaHangGC", SqlDbType.NVarChar, 10);
                cmd.Parameters["@MaHangGC"].Value = _mahanggc;

                cmd.Parameters.Add("@SoLuong", SqlDbType.Int);
                cmd.Parameters["@SoLuong"].Value = _soluong;

                cmd.Parameters.Add("@DonGia", SqlDbType.Money);
                cmd.Parameters["@DonGia"].Value = (decimal)_dongia;

                cmd.ExecuteNonQuery();
                return true;
            }
            catch (System.Exception ex)
            {
                return false;
            }
        }
    }
}
